package com.alan.server.service.impl;

import com.alan.server.entity.DemoUser;
import com.alan.server.mapper.DemoUserMapper;
import com.alan.server.service.IDemoUserService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.alan.server.enums.ServiceErrorCodeEnum;
import com.alan.server.exception.ServiceException;
import org.apache.ibatis.exceptions.TooManyResultsException;

/**
 * <p>
 * 测试用户表 服务实现类
 * </p>
 *
 * @author alan
 * @since 2017-11-04
 */
@Service
public class DemoUserServiceImpl extends ServiceImpl<DemoUserMapper, DemoUser> implements IDemoUserService {

    @Override
    public DemoUser selectOnlyOne(DemoUser entity) throws ServiceException{
        try {
            DemoUser result = baseMapper.selectOne(entity);
            return result;
        }catch (TooManyResultsException ex){
            throw new ServiceException(ServiceErrorCodeEnum.DATA_NOT_UNIQUE);
        }
    }

}
